package com.ding.easycontroller.utils;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class ElementUtils {

    //从文件中读取一个元素
    public static Element readElement(File file) {
        InputStream is = null;
        try {
            SAXBuilder saxBuilder = new SAXBuilder();
            is = new FileInputStream(file);
            Document document = saxBuilder.build(is);
            return document.getRootElement();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            try {
                if (is != null)
                    is.close();
            } catch (IOException ignore) {
            }
        }
    }



}
